def get_user_perms(user):
    all_perms = user.get_all_permissions()
    qidian_perms = [
        perm.split('.')[1]
        for perm in all_perms if perm.split('.')[0]
    ]
    return qidian_perms


def jwt_response_payload_handler(token, user=None, request=None):
    payload = {
        'token': token,
        'username': user.username,
        'email': user.email,
    }
    return payload
